package com.desksoft.ecommerce.helper.mall;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import org.apache.commons.beanutils.BeanComparator;

import com.desksoft.ecommerce.vo.mall.CategoryVO;
import com.desksoft.ecommerce.vo.mall.SearchItemVO;
import com.desksoft.ecommerce.vo.mall.SearchItemsVO;
import com.desksoft.utility.date.DateUtil;
import com.desksoft.utility.string.StringUtil;

/***************************************
 * <pre>
 * 版权所有：杭州迪科软件 保留所有权利
 * 创建日期: 2012-5-5
 * 创建作者：rq
 * 文件名称：SearchItemManager.java
 * 版本：1.0
 * 功能：
 * 最后修改时间：2012-5-5
 * 修改记录：
 * </pre>
 *****************************************/
public class SearchItemsManager implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private SearchItemsVO searchItemsVO;

	public int getNowWeek() {
		return getWeek(new Date());
	}

	public int getWeek(Date date) {
		int temp = DateUtil.getIWeekDate(date);
		if (temp == 1) {
			temp = 8;
		}
		return --temp;
	}

	public void updateSearchItemVO(SearchItemVO searchItemVO) {
		if (SearchItemDataHelper.PAGINATION_TYPE.equals(searchItemVO.getType())) {
			this.getSearchItemsVO().setPage(searchItemVO);
		} else if (SearchItemDataHelper.LISTMODE_TYPE.equals(searchItemVO.getType())) {
			this.getSearchItemsVO().setListmode(searchItemVO);
		} else if (SearchItemDataHelper.SEARCHKEYWOD_TYPE.equals(searchItemVO.getType())) {
			this.getSearchItemsVO().setSearchKeyWord(searchItemVO.getValue());
		}
	}

	/**
	 * @param cp
	 * @param pp
	 * @param ddindex
	 * @param mode
	 * @param order
	 */
	public void init(int cp, int pp, int ddindex, String mode, String order) {
		this.initPage(cp, pp);
		this.initListMode(mode);
		this.searchItemsVO.setDdindex(ddindex);
		this.initOrder(order);
	}

	/**
	 * 
	 * @param cp
	 * @param pp
	 * @param order
	 */
	public void init(int cp, int pp, String order) {
		this.initPage(cp, pp);
		this.initOrder(order);
	}

	public void initOrder(String order) {
		if ("orderSoldNum".equals(order)) {
			SearchItemVO svo = new SearchItemVO();
			svo.setValue("on");
			svo.setType(SearchItemDataHelper.ORDERSOLDNUM_TYPE);
			this.addSearchItemVO(svo);
		} else if ("newpro".equals(order)) {
			SearchItemVO svo = new SearchItemVO();
			svo.setValue("on");
			svo.setType(SearchItemDataHelper.NEWPRODUCTS_TYPE);
			this.addSearchItemVO(svo);
		} else if ("orderPrice".equals(order)) {
			SearchItemVO svo = new SearchItemVO();
			svo.setValue("on2");
			svo.setType(SearchItemDataHelper.ORDERPRICE_TYPE);
			this.addSearchItemVO(svo);
		} else if ("comment".equals(order)) {
			SearchItemVO svo = new SearchItemVO();
			svo.setValue("on");
			svo.setType(SearchItemDataHelper.ORDERCOMMENT_TYPE);
			this.addSearchItemVO(svo);
		}
	}

	public void initPage(int cpage, int ppage) {
		SearchItemVO searchItemVO = new SearchItemVO();
		searchItemVO.setCode("");
		searchItemVO.setName("初始化分页操作");
		searchItemVO.setOpat("change");
		searchItemVO.setType(SearchItemDataHelper.PAGINATION_TYPE);
		searchItemVO.setValue(cpage + "-" + ppage);
		this.searchItemsVO.setPage(searchItemVO);
	}

	public void initListMode(String mode) {
		SearchItemVO listmode = new SearchItemVO();
		listmode.setCode("");
		listmode.setName("初始化显示模式");
		listmode.setOpat("update");
		listmode.setType(SearchItemDataHelper.LISTMODE_TYPE);
		listmode.setValue(mode);
		this.searchItemsVO.setListmode(listmode);
	}

	/**
	 * 检查是否存在fathercode
	 * 
	 * @return
	 */
	public boolean isSearchFatherCode() {
		return !StringUtil.isNull(this.searchItemsVO.getSearchfatherCode());
	}

	/**
	 * 获取fathercode
	 * 
	 * @return
	 */
	public String getSearchFatherCode() {
		return this.searchItemsVO.getSearchfatherCode();
	}

	/**
	 * 检查是否存在fathercode
	 * 
	 * @return
	 */
	public boolean isFatherCode() {
		return !StringUtil.isNull(this.searchItemsVO.getFatherCode());
	}

	/**
	 * 获取fathercode
	 * 
	 * @return
	 */
	public String getFatherCode() {
		return this.searchItemsVO.getFatherCode();
	}

	/**
	 * @return
	 */
	public boolean isPage() {
		return this.isNotNull(this.getSearchItemsVO().getPage());
	}

	/**
	 * @return
	 */
	public int getPageNo() {
		if (!this.isPage()) {
			return 1;
		}
		return Integer.parseInt(this.getSearchItemsVO().getPage().getValue().split("-")[0]);
	}

	public int getTotalCount() {
		if (!this.isPage()) {
			return 1;
		}
		return this.getSearchItemsVO().getPage().getCode() == null
				|| "".equals(this.getSearchItemsVO().getPage().getCode()) ? 0 : Integer.parseInt(this
				.getSearchItemsVO().getPage().getCode());
	}

	/**
	 * @return
	 */
	public int getPageSize() {
		if (!this.isPage()) {
			return 10;
		}
		return Integer.parseInt(this.getSearchItemsVO().getPage().getValue().split("-")[1]);
	}

	public SearchItemsVO getSearchItemsVO() {
		return searchItemsVO;
	}

	public boolean isListMode() {
		return this.isNotNull(this.searchItemsVO.getListmode());
	}

	public String getListMode() {
		if (this.searchItemsVO.getListmode() == null || this.searchItemsVO.equals("")) {
			return "";
		}
		return this.searchItemsVO.getListmode().getValue();
	}

	public boolean isOrderDef() {
		return this.isNotNull(this.searchItemsVO.getOrderDef());
	}

	public String getOrderDef() {
		if (isOrderDef()) {
			return this.searchItemsVO.getOrderDef().getValue();
		}
		return "";
	}

	public boolean isSearchKeyWord() {
		return !StringUtil.isNull(this.searchItemsVO.getSearchKeyWord());
	}

	public String getSearchKeyWord() {
		return this.searchItemsVO.getSearchKeyWord();
	}

	public boolean isMinMaxPrice() {
		return this.isNotNull(this.searchItemsVO.getMinmaxprice());
	}

	public boolean isKeyWord() {
		return this.isNotNull(this.searchItemsVO.getKeyword());
	}

	public boolean isNewProducts() {
		return this.isNotNull(this.searchItemsVO.getNewProducts());
	}

	public String getNewProducts() {
		if (isNewProducts()) {
			return this.searchItemsVO.getNewProducts().getValue();
		}
		return "newpro_default";
	}

	public boolean isOrderPrice() {
		return this.isNotNull(this.searchItemsVO.getOrderPrice());
	}

	public String getOrderPrice() {
		if (isOrderPrice()) {
			return this.searchItemsVO.getOrderPrice().getValue();
		}
		return "price_default";
	}

	public boolean isOrderSoldNum() {
		return this.isNotNull(this.searchItemsVO.getOrderSoldNum());
	}

	public boolean isOrderComment() {
		return this.isNotNull(this.searchItemsVO.getOrderComment());
	}

	public String getOrderComment() {
		if (isOrderComment()) {
			return this.searchItemsVO.getOrderComment().getValue();
		}
		return "comment_default";
	}

	public String getOrderSoldNum() {
		if (isOrderSoldNum()) {
			return this.searchItemsVO.getOrderSoldNum().getValue();
		}
		return "sales_default";
	}

	/**
	 * 获取关键字
	 * 
	 * @return
	 */
	public String getKeyWord() {
		if (isKeyWord()) {
			return this.searchItemsVO.getKeyword().getValue();
		}
		return "";
	}

	/**
	 * @return
	 */
	public String[] getMinMaxPrice() {
		if (isMinMaxPrice())
			return this.searchItemsVO.getMinmaxprice().getValue().split(SearchItemDataHelper.fgsign);
		return new String[] { "", "" };
	}

	/**
	 * @return
	 */
	public boolean isMinDistQty() {
		return this.isNotNull(this.searchItemsVO.getMinDistQty());
	}

	/**
	 * 获取最小起批量
	 * 
	 * @return
	 */
	public String getMinDistQty() {
		if (isMinDistQty()) {
			return searchItemsVO.getMinDistQty().getValue();
		}
		return "";
	}

	/**
	 * @param searchItemsVO
	 */
	public SearchItemsManager(SearchItemsVO searchItemsVO) {
		this.searchItemsVO = searchItemsVO;
	}

	/**
	 * @return
	 */
	public List<SearchItemVO> toList() {
		List<SearchItemVO> result = new ArrayList<SearchItemVO>();
		if (null != searchItemsVO.getCategoryD()) {
			result.add(searchItemsVO.getCategoryD());
		}
		if (null != searchItemsVO.getCategoryZ()) {
			result.add(searchItemsVO.getCategoryZ());
		}
		if (null != searchItemsVO.getCategory()) {
			result.add(searchItemsVO.getCategory());
		}
		if (null != searchItemsVO.getBrand()) {
			result.add(searchItemsVO.getBrand());
		}
		if (null != searchItemsVO.getPrice()) {
			result.add(searchItemsVO.getPrice());
		}
		if (null != searchItemsVO.getDescs()) {
			result.addAll(searchItemsVO.getDescs());
		}
		if (null != searchItemsVO.getSearchKeyWord()) {
			// result.addAll();
		}
		return result;
	}

	/**
	 * @return
	 */
	public String getBrand() {
		if (isBrand()) {
			return this.searchItemsVO.getBrand().getName();
		}
		return "";
	}

	/**
	 * @return
	 */
	public String getCategoryCode() {
		if (isCategory()) {
			return this.searchItemsVO.getCategory().getCode().split(SearchItemDataHelper.fgsign)[0];
		}
		if (isCategoryZ()) {
			return this.searchItemsVO.getCategoryZ().getCode().split(SearchItemDataHelper.fgsign)[0];
		}
		if (isCategoryD()) {
			return this.searchItemsVO.getCategoryD().getCode().split(SearchItemDataHelper.fgsign)[0];
		}
		return "";
	}

	public String getCategoryD() {
		if (isCategoryD()) {
			return this.searchItemsVO.getCategoryD().getCode().split(SearchItemDataHelper.fgsign)[0];
		}
		return "";
	}

	public String getCategoryDname() {
		if (isCategoryD()) {
			return this.searchItemsVO.getCategoryD().getName();
		}
		return "";
	}

	public String getCategoryZ() {
		if (isCategoryZ()) {
			return this.searchItemsVO.getCategoryZ().getCode().split(SearchItemDataHelper.fgsign)[0];
		}
		return "";
	}

	public String getCategoryZname() {
		if (isCategoryZ()) {
			return this.searchItemsVO.getCategoryZ().getName();
		}
		return "";
	}

	public String getCategory() {
		if (isCategory()) {
			return this.searchItemsVO.getCategory().getCode().split(SearchItemDataHelper.fgsign)[0];
		}
		return "";
	}

	public String getCategoryname() {
		if (isCategoryZ()) {
			return this.searchItemsVO.getCategory().getName();
		}
		return "";
	}

	/**
	 * @return
	 */
	public String getClazz() {
		if (isCategory()) {
			return this.searchItemsVO.getCategory().getCode().split(SearchItemDataHelper.fgsign)[1];
		}
		if (isCategoryZ()) {
			return this.searchItemsVO.getCategoryZ().getCode().split(SearchItemDataHelper.fgsign)[1];
		}
		if (isCategoryD()) {
			return this.searchItemsVO.getCategoryD().getCode().split(SearchItemDataHelper.fgsign)[1];
		}
		return "1";
	}

	/**
	 * @param list
	 * @return
	 */
	public String getSelectedIds() {
		StringBuffer result = new StringBuffer();

		for (SearchItemVO vo : this.toList()) {
			if (result.length() > 0)
				result.append(SearchItemDataHelper.sign);
			result.append(vo.getCode() + SearchItemDataHelper.idSign + vo.getType());
		}
		return result.toString();
	}

	/**
	 * 添加一个搜索条件
	 * 
	 * @param vo
	 */
	public void addSearchItemVO(SearchItemVO vo) {
		vo.setIndex(this.getIndex());
		if (SearchItemDataHelper.CATE_TYPE.equals(vo.getType())) {
			if (vo.getCode().split(SearchItemDataHelper.fgsign)[1].equals("2")
					&& !this.isNotNull(searchItemsVO.getCategoryD())) {
				this.searchItemsVO.setCategoryD(vo);

			} else if (vo.getCode().split(SearchItemDataHelper.fgsign)[1].equals("3")
					&& !this.isNotNull(searchItemsVO.getCategoryZ())) {
				this.searchItemsVO.setCategoryZ(vo);

			} else if (vo.getCode().split(SearchItemDataHelper.fgsign)[1].equals("4")
					&& !this.isNotNull(searchItemsVO.getCategory())) {
				this.searchItemsVO.setCategory(vo);

			}
		} else if (SearchItemDataHelper.BRAND_TYPE.equals(vo.getType()) && !this.isNotNull(searchItemsVO.getBrand())) {
			this.searchItemsVO.setBrand(vo);

		} else if (SearchItemDataHelper.PRICE_TYPE.equals(vo.getType()) && !this.isNotNull(searchItemsVO.getPrice())) {
			this.searchItemsVO.setPrice(vo);

		} else if (SearchItemDataHelper.DESC_TYPE.equals(vo.getType())) {
			if (this.searchItemsVO.getDescs() == null) {
				this.searchItemsVO.setDescs(new ArrayList<SearchItemVO>());
			}
			if (!this.searchItemsVO.getDescs().contains(vo)) {
				this.searchItemsVO.getDescs().add(vo);
			}
		} else if (SearchItemDataHelper.NEWPRODUCTS_TYPE.equals(vo.getType())) {
			searchItemsVO.setNewProducts(vo);
			searchItemsVO.setOrderComment(null);
			searchItemsVO.setOrderPrice(null);
			searchItemsVO.setOrderSoldNum(null);
			searchItemsVO.setOrderDef(vo);
		} else if (SearchItemDataHelper.ORDERPRICE_TYPE.equals(vo.getType())) {
			searchItemsVO.setOrderPrice(vo);
			searchItemsVO.setOrderComment(null);
			searchItemsVO.setNewProducts(null);
			searchItemsVO.setOrderSoldNum(null);
			searchItemsVO.setOrderDef(vo);
		} else if (SearchItemDataHelper.ORDERSOLDNUM_TYPE.equals(vo.getType())) {
			searchItemsVO.setOrderSoldNum(vo);
			searchItemsVO.setOrderComment(null);
			searchItemsVO.setOrderPrice(null);
			searchItemsVO.setNewProducts(null);
			searchItemsVO.setOrderDef(vo);
		} else if (SearchItemDataHelper.ORDERCOMMENT_TYPE.equals(vo.getType())) {
			searchItemsVO.setOrderComment(vo);
			searchItemsVO.setOrderSoldNum(null);
			searchItemsVO.setOrderPrice(null);
			searchItemsVO.setNewProducts(null);
			searchItemsVO.setOrderDef(vo);
		} else if (SearchItemDataHelper.UPPAGE_TYPE.equals(vo.getType())) {
			searchItemsVO.setUppage(vo);
		} else if (SearchItemDataHelper.DOWNPAGE_TYPE.equals(vo.getType())) {
			searchItemsVO.setDownpage(vo);
		} else if (SearchItemDataHelper.MINDISTQTY_TYPE.equals(vo.getType())) {
			searchItemsVO.setMinDistQty(vo);
		} else if (SearchItemDataHelper.MINMAXPRICE_TYPE.equals(vo.getType())) {
			searchItemsVO.setMinmaxprice(vo);
		} else if (SearchItemDataHelper.KEYWORD_TYPE.equals(vo.getType())) {
			searchItemsVO.setKeyword(vo);
		} else if (SearchItemDataHelper.ORDER_DEF.equals(vo.getType())) {
			searchItemsVO.setOrderDef(vo);
		}

		// this.initPage();
	}

	/**
	 * 删除一个搜索条件
	 * 
	 * @param vo
	 */
	public void delSearchItemVO(SearchItemVO vo) {
		if (SearchItemDataHelper.CATE_TYPE.equals(vo.getType())) {
			if (vo.getCode().split(SearchItemDataHelper.fgsign)[1].equals("2")) {
				String categoryCodeD = vo.getCode().split(SearchItemDataHelper.fgsign)[0];
				String categoryCodeZ = null;
				String categoryCode = null;
				if (this.isCategoryZ()) {
					categoryCodeZ = this.getSearchItemsVO().getCategoryZ().getCode().split(SearchItemDataHelper.fgsign)[0];
				}
				if (this.isCategory()) {
					categoryCode = this.getSearchItemsVO().getCategory().getCode().split(SearchItemDataHelper.fgsign)[0];
				}

				this.searchItemsVO.setCategoryD(null);
				this.searchItemsVO.setCategoryZ(null);
				this.searchItemsVO.setCategory(null);
				setNullByGategoryCode(categoryCodeD);
				if (!StringUtil.isNull(categoryCodeZ))
					setNullByGategoryCode(categoryCodeZ);
				if (!StringUtil.isNull(categoryCode))
					setNullByGategoryCode(categoryCode);

			} else if (vo.getCode().split(SearchItemDataHelper.fgsign)[1].equals("3")) {
				String categoryCodeZ = vo.getCode().split(SearchItemDataHelper.fgsign)[0];
				String categoryCode = null;
				if (this.isCategory()) {
					categoryCode = this.getSearchItemsVO().getCategory().getCode().split(SearchItemDataHelper.fgsign)[0];
				}
				// String
				this.searchItemsVO.setCategoryZ(null);
				this.searchItemsVO.setCategory(null);
				setNullByGategoryCode(categoryCodeZ);
				if (!StringUtil.isNull(categoryCode))
					setNullByGategoryCode(categoryCode);
			} else if (vo.getCode().split(SearchItemDataHelper.fgsign)[1].equals("4")) {
				String categoryCode = vo.getCode().split(SearchItemDataHelper.fgsign)[0];
				this.searchItemsVO.setCategory(null);
				setNullByGategoryCode(categoryCode);
			}
		} else if (SearchItemDataHelper.BRAND_TYPE.equals(vo.getType())) {
			searchItemsVO.setBrand(null);
		} else if (SearchItemDataHelper.PRICE_TYPE.equals(vo.getType())) {
			searchItemsVO.setPrice(null);
		} else if (SearchItemDataHelper.DESC_TYPE.equals(vo.getType())) {
			if (null != this.searchItemsVO.getDescs()) {
				searchItemsVO.getDescs().remove(vo);
			}
		}

		else if (SearchItemDataHelper.NEWPRODUCTS_TYPE.equals(vo.getType())) {
			searchItemsVO.setNewProducts(null);
		} else if (SearchItemDataHelper.ORDERPRICE_TYPE.equals(vo.getType())) {
			searchItemsVO.setOrderPrice(null);
		} else if (SearchItemDataHelper.ORDERSOLDNUM_TYPE.equals(vo.getType())) {
			searchItemsVO.setOrderSoldNum(null);
		} else if (SearchItemDataHelper.ORDERCOMMENT_TYPE.equals(vo.getType())) {
			searchItemsVO.setOrderComment(null);
		} else if (SearchItemDataHelper.UPPAGE_TYPE.equals(vo.getType())) {
			searchItemsVO.setUppage(null);
		} else if (SearchItemDataHelper.DOWNPAGE_TYPE.equals(vo.getType())) {
			searchItemsVO.setDownpage(null);
		} else if (SearchItemDataHelper.MINDISTQTY_TYPE.equals(vo.getType())) {
			searchItemsVO.setMinDistQty(null);
		} else if (SearchItemDataHelper.MINMAXPRICE_TYPE.equals(vo.getType())) {
			searchItemsVO.setMinmaxprice(null);
		} else if (SearchItemDataHelper.KEYWORD_TYPE.equals(vo.getType())) {
			searchItemsVO.setKeyword(null);
		} else if (SearchItemDataHelper.ORDER_DEF.equals(vo.getType())) {
			searchItemsVO.setOrderDef(null);
		}
		// this.initPage();
	}

	private void setNullByGategoryCode(String categoryCode) {
		this.searchItemsVO.setCategory(null);
		// 删除关联的品牌
		if (isBrand()) {
			if (categoryCode.equals(this.searchItemsVO.getBrand().getCategoryCode())) {
				searchItemsVO.setBrand(null);
			}
		}

		// 删除关联的价格区间
		if (isPrice()) {
			if (categoryCode.equals(this.searchItemsVO.getPrice().getCategoryCode())) {
				searchItemsVO.setPrice(null);
			}
		}

		// 删除关联的特征
		if (isDesc()) {
			List<SearchItemVO> remove = new ArrayList<SearchItemVO>();
			for (SearchItemVO searchItemVO : this.searchItemsVO.getDescs()) {
				if (categoryCode.equals(searchItemVO.getCategoryCode())) {
					remove.add(searchItemVO);
				}
			}
			for (SearchItemVO searchItemVO : remove) {
				this.searchItemsVO.getDescs().remove(searchItemVO);
			}
		}
	}

	/**
	 * 检查特征码条件是否已经选择
	 * 
	 * @param vo
	 * @return
	 */
	public boolean isDesc(SearchItemVO vo) {
		boolean result = false;
		for (SearchItemVO searchItemVO : this.searchItemsVO.getDescs()) {
			if (searchItemVO.equals(vo)) {
				result = true;
				break;
			}
		}
		return result;
	}

	public List<String> getDesc() {
		List<String> list = new ArrayList<String>();
		if (null != this.searchItemsVO.getDescs())
			for (SearchItemVO vo : this.searchItemsVO.getDescs()) {
				list.add(vo.getCode().split(SearchItemDataHelper.fgsign, -1)[0]);
			}
		return list;
	}

	/**
	 * @return
	 */
	public boolean isCategorys() {
		if (this.isCategory())
			return true;
		if (this.isCategoryZ())
			return true;
		if (this.isCategoryD())
			return true;
		return false;
	}

	/**
	 * @param vo
	 * @return
	 */
	private boolean isNotNull(SearchItemVO vo) {
		return null != vo;
	}

	/**
	 * @return
	 */
	public boolean isCategoryD() {
		return isNotNull(this.searchItemsVO.getCategoryD());
	}

	/**
	 * @return
	 */
	public boolean isCategoryZ() {
		return isNotNull(this.searchItemsVO.getCategoryZ());
	}

	/**
	 * @return
	 */
	public boolean isCategory() {
		return isNotNull(this.searchItemsVO.getCategory());
	}

	/**
	 * @return
	 */
	public boolean isBrand() {
		return isNotNull(this.searchItemsVO.getBrand());
	}

	/**
	 * @return
	 */
	public boolean isPrice() {
		return isNotNull(this.searchItemsVO.getPrice());
	}

	public String[] getPrice() {
		String[] result = new String[] { "", "" };
		String temp = this.searchItemsVO.getPrice().getName();
		if (temp.contains("万")) {
			if (temp.contains("以上")) {
				result[0] = temp.replaceAll("万", "").replace("以上", "").replace("元", "") + "0000";
				result[1] = "max";
			} else {
				result = temp.split("-");
				result[0] = result[0].replace("万", "") + "0000";
				result[1] = result[0].replace("万", "").replace("元", "") + "0000";
			}
		} else {
			if (temp.contains("以上")) {
				result[0] = temp.replaceAll("元", "").replace("以上", "");
				result[1] = "max";
			} else {
				result = temp.split("-");
				result[0] = result[0].replace("元", "");
				result[1] = result[1].replace("元", "");
			}
		}
		return result;
	}

	/**
	 * @return
	 */
	public boolean isDesc() {
		return null != this.searchItemsVO.getDescs() && this.searchItemsVO.getDescs().size() > 0;
	}

	/**
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public long getIndex() {
		List<SearchItemVO> list = this.toList();
		if (list.size() == 0)
			return 0;
		Collections.sort(list, new BeanComparator("index"));
		return list.get(list.size() - 1).getIndex() + 1;
	}

	public int getDdIndex() {
		return this.searchItemsVO.getDdindex();
	}

	public String getCategoryClass() {
		String categoryClass = CategoryVO.CALSS_BIG;
		if (this.isCategoryD()) {
			categoryClass = CategoryVO.CALSS_MIDDLE;
		}
		if (this.isCategoryZ()) {
			categoryClass = CategoryVO.CALSS_LITTLE;
		}
		return categoryClass;
	}

	public String getFullPromotion() {
		return this.searchItemsVO.getFullPromotion();
	}

	public String getVendorCode() {
		return this.searchItemsVO.getVendorCode();
	}

	public String getStorecode() {
		return this.searchItemsVO.getStorecode();
	}

	/**
	 * 
	 * @param searchItem
	 */
	public void opatSearchItemVO(SearchItemVO searchItem) {
		if (SearchItemVO.OPAT_ADD.equals(searchItem.getOpat())) {
			this.addSearchItemVO(searchItem);
		} else if (SearchItemVO.OPAT_DEL.equals(searchItem.getOpat())) {
			this.delSearchItemVO(searchItem);
		} else if (SearchItemVO.OPAT_UPD.equals(searchItem.getOpat())) {
			this.updateSearchItemVO(searchItem);
		}
	}

	public String getSeo() {
		if (isCategory()) {
			return this.searchItemsVO.getCategory().getName();
		}
		if (isCategoryZ()) {
			return this.searchItemsVO.getCategoryZ().getName();
		}
		if (isCategoryD()) {
			return this.searchItemsVO.getCategoryD().getName();
		}
		if (isBrand()) {
			return this.searchItemsVO.getBrand().getName();
		}
		if (isSearchKeyWord()) {
			return this.searchItemsVO.getSearchKeyWord();
		}
		return null;
	}

}
